﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>4.数据库配置</title>
    <script type="text/javascript" src="../Content/highlighter/scripts/shCore.js"></script>
    <script type="text/javascript" src="../Content/highlighter/scripts/shBrushJScript.js"></script>
    <link type="text/css" rel="stylesheet" href="../Content/highlighter/styles/shCoreDefault.css"/>
    <script type="text/javascript">SyntaxHighlighter.all();</script>
</head>
<body>
	<h3>数据库配置</h3>
    <p>
    1.配置Web.Config中的ConnectionString
    </p>
    mysql数据库:
    <pre class="brush: javascript;">
    "connectionStrings": [
		{
        	"name": "MySql",
		    "connectionString": "Server=localhost;Database=test;Uid=root;Pwd=root;",
		    "providerName": "MySql.Data.MySqlClient"
		}]
    </pre>
    sqlite数据库:
    <pre class="brush: javascript;">
    "connectionStrings": [
		{
        	"name": "Sqlite",
		    "connectionString": "Data Source=|ModuleDataDirectory|Common.db;Pooling=true;FailIfMissing=false",
		    "providerName": "System.Data.SQLite"
		}]
    </pre>
    sqlserver数据库:
    <pre class="brush: javascript;">
    "connectionStrings": [
		{
            "name": "SqlServer",
            "connectionString": "Server=.\\SQLEXPRESS;Database=test;Uid=sa;Pwd=123456;",
            "providerName": "System.Data.SqlClient"
		}]
    </pre>
    oracle数据库:
    <pre class="brush: javascript;">
    "connectionStrings": [
		{
            "name": "Oracle",
            "connectionString": "Data Source==(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ORCL)));User Id=c##sa;Password=123456;",
            "providerName": "Oracle.ManagedDataAccess.Client"
		}]
    </pre>
    postgresql数据库:
    <pre class="brush: javascript;">
    "connectionStrings": [
		{
            "name": "PostgreSql",
            "connectionString": "Server=localhost;DataBase=postgres;Uid=postgres;Pwd=123456;",
            "providerName": "Npgsql"
		}]
    </pre>
    <p>
    2.运行WebCompile.aspx生成数据库操作类.
    </p>
    <p>
    3.打开Models目录,显示所有文件,把生成的数据库操作类添加进项目中.
    </p>
</body>
</html>
